﻿@model List<MenuDTO>
@{
    var menu = Model.FirstOrDefault(t => t.Code == ViewBag.CurrentMenu);
}
    <header class="main-header">
        <!--Logo-->
        <a href="#" class="logo">
            <!--mini logo for sidebar mini 50x50 pixels-->
            <span class="logo-mini"><b>A</b>LT</span>
            <!--logo for regular state and monbile decices-->
            <span class="logo-lg"><b>Admin</b>LTE</span>
        </a>

        <!-- Header Navbar -->
        <nav class="navbar navbar-static-top" role="navigation">
            <!-- Sidebar toggle button-->
            <a href="#" class="sidebar-toggle" data-toggle="push-menu" role="button">
                <span class="sr-only">Toggle navigation</span>
            </a>
            <!-- Navbar Right Menu -->
            <div class="navbar-custom-menu">
                <ul class="nav navbar-nav">
                    <!-- User Account Menu -->
                    <li class="dropdown user user-menu">
                        <!-- Menu Toggle Button -->
                        <a href="#" class="dropdown-toggle" data-toggle="dropdown">
                            <!-- The user image in the navbar-->
                            <img src="~/lib/AdminLTE/img/user2-160x160.jpg" class="user-image" alt="User Image">
                            <!-- hidden-xs hides the username on small devices so only the image appears. -->
                            <span class="hidden-xs">@ViewBag.UserInfo.Name</span>
                        </a>
                        <ul class="dropdown-menu">
                            <!-- User image -->
                            <li class="user-header">
                                <img src="~/lib/AdminLTE/img/user2-160x160.jpg" class="img-circle" alt="User Image">

                                <p>
                                    @ViewBag.UserInfo.Name
                                    <small>@ViewBag.UserInfo.Code</small>
                                </p>
                            </li>
                            <!-- Menu Footer-->
                            <li class="user-footer">
                                <div class="pull-left">
                                    <a href="#" class="btn btn-default btn-flat">Profile</a>
                                </div>
                                <div class="pull-right">
                                    <a href="#" class="btn btn-default btn-flat">Sign out</a>
                                </div>
                            </li>
                        </ul>
                    </li>
                </ul>
            </div>
        </nav>
    </header>
    <aside class="main-sidebar">
        <section class="sidebar">

            <div class="user-panel">
                <div class="pull-left image">
                    <img src="~/lib/AdminLTE/img/user2-160x160.jpg" class="img-circle" alt="User Image" />
                </div>
                <div class="pull-left info">
                    <p>@ViewBag.UserInfo.Name</p>
                    <a href="#"><i class="fa fa-circle text-success"></i></a>
                </div>
            </div>

            <form action="#" method="get" class="sidebar-form">
                <div class="input-group">
                    <input type="text" name="q" class="form-control" placeholder="Search..." />
                    <span class="input-group-btn">
                        <button type="submit" name="search" id="search=btn" class="btn btn-flat">
                            <i class="fa fa-search"></i>
                        </button>
                    </span>
                </div>
            </form>

            <ul class="sidebar-menu" data-widget="tree">
                <li class="header">菜单栏</li>

                @foreach (var item in Model.Where(t => t.Type == 0).ToList())
                {
                    var isOpen = item.ID == menu?.ParentID;//判断当前菜单是否open
                    <li class="@(isOpen ? "treeview menu-open" : "treeview")">
                        <a href="@item.Url">
                            <i class="fa fa-folder"></i>
                            <span>@item.Name</span>
                            <span class="pull-right-container">
                                <i class="fa fa-angle-left pull-right"></i>
                            </span>
                        </a>

                        <ul class="treeview-menu" style="display: @(isOpen ? "block" : "none");">
                            @foreach (var detail in Model.Where(t => t.ParentID == item.ID && t.Type == 1).OrderBy(t => t.SerialNumber))
                            {
                                var isActive = ViewBag.CurrentMenu == detail.Code;//判断当前功能是否active
                                <li class="@(isActive ? "active" : "")">
                                    <a href="@detail.Url">
                                        <i class="fa @detail.Icon"></i>
                                        @detail.Name
                                    </a>
                                </li>
                            }
                        </ul>
                    </li>

                }
            </ul>

        </section>

    </aside>

